package com.tnmi.log;

import com.tnmi.log.aspects.SysLogAspects;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @Classname LogAutoConfiguration
 * @Description TODO 日志自动配置
 * 启动条件：
 * 1.存在web环境
 * 2.配置文件中tsunami.log.enabled=true
 * 3.配置文件中不存在：tsunami.log.enabled值
 * @Date 2021-09-18 17:39
 * @Created by lx
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
@ConditionalOnProperty(name = "tnmi.log.enabled", havingValue = "true",matchIfMissing = true)
public class LogAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public SysLogAspects sysLogAspect(){
        return new SysLogAspects();
    }
}
